home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / pd mix ii / access / thai / scan.c < prev    next >
C/C++ Source or Header  |  1994-05-20  |  4KB  |  170 lines

  1.  
  2. #include "quiz.h"
  3.  
  4.  
  5. reset_next_prev ()
  6. {
  7. #ifdef USE_ON_OFF
  8.     if ( more ( PREV_ENTRY ) )
  9.         OnGadget ( &CmdGadget[ PREV_ENTRY ] , window , (LONG)NULL );
  10.     else
  11.         OffGadget ( &CmdGadget[ PREV_ENTRY ] , window , (LONG)NULL );
  12.     if ( more ( NEXT_ENTRY ) )
  13.         OnGadget ( &CmdGadget[ NEXT_ENTRY ] , window , (LONG)NULL );
  14.     else
  15.         OffGadget ( &CmdGadget[ NEXT_ENTRY ] , window , (LONG)NULL );
  16. #endif
  17. }
  18.  
  19.  
  20. more ( direction )
  21. int direction;
  22. {
  23.     char *p;
  24.  
  25.     switch ( scanning ) {
  26.  
  27.     case CHOOSE_SENTENCE :
  28.         p = wordptr;
  29.         if ( direction == PREV_ENTRY ) {
  30.             if ( p == chosen_sentence->thai )
  31.                 return ( FALSE );
  32.             else
  33.                 return ( TRUE );
  34.         }
  35.         else {
  36.             while ( *p != TC_SPACE  &&  *p != '\0' )
  37.                 p++;
  38.             return ( *p == TC_SPACE );
  39.         }
  40.  
  41.     case TS_SEARCH :
  42.         return ( thai_search ( chosen_sentence , screen_sentence.thai ,
  43.             direction ) != NULL );
  44.  
  45.     case PS_SEARCH :
  46.         return ( phonetic_search ( chosen_sentence , screen_sentence.phonetic ,
  47.             direction ) != NULL );
  48.  
  49.     case ES_SEARCH :
  50.         return ( english_search ( chosen_sentence , screen_sentence.english ,
  51.             direction ) != NULL );
  52.  
  53.     case TW_SEARCH :
  54.         return ( thai_search ( chosen_word , screen_word.thai ,
  55.             direction ) != NULL );
  56.  
  57.     case PW_SEARCH :
  58.         return ( phonetic_search ( chosen_word , screen_word.phonetic ,
  59.             direction ) != NULL );
  60.  
  61.     case EW_SEARCH :
  62.         return ( english_search ( chosen_word , screen_word.english ,
  63.             direction ) != NULL );
  64.  
  65.     }
  66.     return ( FALSE );
  67. }
  68.  
  69.  
  70. do_scan ( direction )
  71. int direction;
  72. {
  73.     char *p;
  74.     char oldc;
  75.  
  76.     switch ( scanning ) {
  77.  
  78.     case CHOOSE_WORD :
  79.         if ( direction == PREV_ENTRY ) {
  80.             if ( cur_split_word > 0 )
  81.                 cur_split_word--;
  82.         }
  83.         else {
  84.             if ( cur_split_word + 1 < num_split_words )
  85.                 cur_split_word++;
  86.         }
  87.         if ( cur_split_word < num_split_words  &&  cur_split_word >= 0 )
  88.             new_word ( split_words[ cur_split_word ] );
  89.         break;
  90.  
  91.     case TS_SEARCH :
  92.         new_sentence ( thai_search ( chosen_sentence , scan.thai ,
  93.             direction ) );
  94.         break;
  95.  
  96.     case PS_SEARCH :
  97.         new_sentence ( phonetic_search ( chosen_sentence , scan.phonetic ,
  98.             direction ) );
  99.         break;
  100.  
  101.     case ES_SEARCH :
  102.         new_sentence ( english_search ( chosen_sentence , scan.english ,
  103.             direction ) );
  104.         break;
  105.  
  106.     case TW_SEARCH :
  107.         new_word ( thai_search ( chosen_word , scan.thai , direction ) );
  108.         break;
  109.  
  110.     case PW_SEARCH :
  111.         new_word ( phonetic_search ( chosen_word , scan.phonetic ,
  112.             direction ) );
  113.         break;
  114.  
  115.     case EW_SEARCH :
  116.         new_word ( english_search ( chosen_word , scan.english ,
  117.             direction ) );
  118.         break;
  119.     }
  120. }
  121.  
  122.  
  123. new_sentence ( sentence )
  124. struct thai_phrase *sentence;
  125. {
  126.     if ( sentence == NULL )
  127.         chosen_sentence = &sentence_head;
  128.     else
  129.         chosen_sentence = sentence;
  130.     if ( show_sentence & SHOW_THAI )
  131.         strcpy ( screen_sentence.thai , chosen_sentence->thai );
  132.     else
  133.         screen_sentence.thai[0] = '\0';
  134.     if ( show_sentence & SHOW_PHONETIC )
  135.         strcpy ( screen_sentence.phonetic , chosen_sentence->phonetic );
  136.     else
  137.         screen_sentence.phonetic[0] = '\0';
  138.     if ( show_sentence & SHOW_ENGLISH )
  139.         strcpy ( screen_sentence.english , chosen_sentence->english );
  140.     else
  141.         screen_sentence.english[0] = '\0';
  142.     RefreshGadgets ( window->FirstGadget , window , (LONG)NULL );
  143.     redraw_thai ( TS_ENTRY );
  144. }
  145.  
  146.  
  147. new_word ( word )
  148. struct thai_phrase *word;
  149. {
  150.     if ( word == NULL )
  151.         chosen_word = &word_head;
  152.     else
  153.         chosen_word = word;
  154.     if ( show_word & SHOW_THAI )
  155.         strcpy ( screen_word.thai , chosen_word->thai );
  156.     else
  157.         screen_word.thai[0] = '\0';
  158.     if ( show_word & SHOW_PHONETIC )
  159.         strcpy ( screen_word.phonetic , chosen_word->phonetic );
  160.     else
  161.         screen_word.phonetic[0] = '\0';
  162.     if ( show_word & SHOW_ENGLISH )
  163.         strcpy ( screen_word.english , chosen_word->english );
  164.     else
  165.         screen_word.english[0] = '\0';
  166.     RefreshGadgets ( window->FirstGadget , window , (LONG)NULL );
  167.     redraw_thai ( TW_ENTRY );
  168. }
  169.  
  170.